package com.test5;

import java.io.BufferedInputStream;
import java.io.FileInputStream;

/**
 * 字节缓冲流
 */
public class BufferedInputStreamTest {
    public static void main(String[] args) throws Exception {
        FileInputStream fis = new FileInputStream("C:\\Users\\LDH\\Desktop\\test2.txt");
        BufferedInputStream bis = new BufferedInputStream(fis); //内部有8k的缓冲区
        //读取
        int data = 0;
        while ((data = bis.read()) != -1){
            System.out.println((char) data);
        }
        //自定义缓冲区读取
        byte[] buf = new byte[1024];
        int count = 0;
        while ((count =fis.read(buf)) != -1){
            System.out.println(new String(buf,0,count));
        }
        bis.close();
    }
}
